package cn.lf.android.lawfirm.conflict.view;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import cn.lf.android.lawfirm.R;
import cn.lf.android.lawfirm.conflict.modle.Conflict;

import static cn.lf.android.lawfirm.R.id.head_left;

public class ConflictAdapter extends BaseAdapter {
    private List<Conflict> list;
    private LayoutInflater inflater;
    private Activity context;
    private int mPosition = 0;

    public ConflictAdapter(Activity context, List<Conflict> list) {
        this.context = context;
        this.list = list;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_conflict, null);
            holder.casename = (TextView) convertView
                    .findViewById(R.id.casename);
            holder.weituo_people = (TextView) convertView
                    .findViewById(R.id.weituo_people);
            holder.duifang_people = (TextView) convertView
                    .findViewById(R.id.duifang_people);
            holder.sheanren_people = (TextView) convertView
                    .findViewById(R.id.sheanren_people);
            holder.chengban_time = (TextView) convertView
                    .findViewById(R.id.chengban_time);
            holder.jiean_time = (TextView) convertView
                    .findViewById(R.id.jiean_time);
            holder.result = (TextView) convertView
                    .findViewById(R.id.result);
            holder.head_right = (TextView) convertView
                    .findViewById(R.id.head_right);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        final Conflict bean = list.get(position);

        holder.casename.setText("案件名称：" + bean.lsysCaseName);
        holder.weituo_people.setText("委托人：" + bean.weiTuoRen);
        holder.duifang_people.setText("对方当事人：" + bean.lsysAdversaryName);
        holder.sheanren_people.setText("涉案人：" + bean.lsysSheAnRen);
        holder.chengban_time.setText("承办时间：暂无返回值");
        holder.jiean_time.setText("结案时间：" + bean.lsysCaseOverDate);
        holder.result.setText("结果：" + bean.conflictRes);
//        holder.head_right.setText(bean.LogStates);
//        holder.right_two.setVisibility(View.GONE);
//        holder.right_one.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent = new Intent(context, WorkLogActivity.class);
//                intent.putExtra("LsysLogID", list.get(position).LsysLogID);
//                intent.putExtra("ID", list.get(position).ID);
//                context.startActivity(intent);
//            }
//        });
        return convertView;
    }

    class ViewHolder {
        TextView head_right, casename, weituo_people, duifang_people, sheanren_people, chengban_time, jiean_time, result;
    }

}
